package com.g3net.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.log4j.MDC;

import com.g3net.tool.RandomUtils;

/** *//**
 * 处理Tomcat 服务器表单编码问题。
 * @author htqx
 * @version 1.0 2008-1-20
 */
public class Log4jFilter implements Filter {

    /** *//**
     * 客户端的编码类型。
     * 默认为 UTF-8
     */
    String encode = "UTF-8";



 
    public void destroy() {

        
    }

   
    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {

    	MDC.put("logid", RandomUtils.getRandomNumberString(6));
        chain.doFilter(request, response);
        MDC.remove("logid");
        
    }


	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}


}
